package cn.jsu.oj.dispatchServer.thread;

import cn.jsu.oj.dispatchServer.factory.CmdHandleFactory;
import cn.jsu.oj.dispatchServer.handle.CommandPack;
import cn.jsu.oj.dispatchServer.pojo.AbstractPack;
import cn.jsu.oj.dispatchServer.resource.Resource;

/**
 * @author ahtonc
 * @date 2021/4/6
 */
public class ErrorHandleThread implements Runnable {
    @Override
    public void run() {
        try {
            while (true)
            {
                CommandPack<AbstractPack> commandPack = Resource.errorQueue.take();

                CmdHandleFactory.getHandle(commandPack.getData().getTypeNo()).handle(commandPack);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
